package com.dykj.platform.framework.common.paging;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.dykj.platform.framework.exception.DatabaseException;

public class HquerySupportDAO implements IHQuerySupportDAO {
	protected Log log = LogFactory.getLog(this.getClass());
	public Hquery createParaQuery(Hquery hquery) throws DatabaseException {
		StringBuffer query_str = new StringBuffer(hquery.getQueryString());
		// 是否要排序
		if (null != hquery.getOrderby() && (!"".equals(hquery.getOrderby()))) {
			query_str.append(hquery.getOrderby());
			if (null != hquery.getSortOrder() && !"".equals(hquery.getSortOrder())) {
				query_str.append(" ");
				query_str.append(hquery.getSortOrder());
			}
			if (log.isInfoEnabled())
				log.info(hquery.getOrderby());
		}
		// 是否要分组
		if (null != hquery.getGroupby() && (!"".equals(hquery.getGroupby()))) {
			query_str.append(hquery.getGroupby());
			if (log.isInfoEnabled())
				log.info(hquery.getGroupby());
		}
		hquery.setQueryString(query_str.toString());
		return hquery;
	}
	}
